/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import BO.ReportBO;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import pojo.Report;
import pojo.User;

/**
 *
 * @author phong
 */
public class ReportListBean {

    private String labID = "";
    private String status = "All";
    private String startDate = "";
    private String endDate = "";
    private List<Report> reports;

    public ReportListBean() {
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getLabID() {
        return labID;
    }

    public void setLabID(String labID) {
        this.labID = labID;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<Report> getReports() {
        return reports;
    }

    public void setReports(List<Report> reports) {
        this.reports = reports;
    }

    //<editor-fold defaultstate="collapsed" desc="Lấy danh sach Report cho Admin">
    public List<Report> getReportByAdmin() {
        this.reports = ReportBO.getReportByAdmin(this.status, this.startDate, this.endDate, this.labID);
        return this.reports;
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Lấy danh sach Report cua 1 technican">
    public List<Report> getReportByTechnican() {
        this.reports = ReportBO.getReportByTechnican();
        return this.reports;
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Lấy danh sach Report can xu ly cua 1 technican">
    public List<Report> getWorkByTechnican() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Map session = facesContext.getExternalContext().getSessionMap();
        User user = (User) session.get("User");
        this.reports = ReportBO.getWorkByTechnican(user.getId());
        return this.reports;
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Lấy danh sach Report cua 1 user">
    public List<Report> getReportByUser() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Map session = facesContext.getExternalContext().getSessionMap();
        User user = (User) session.get("User");
        this.reports = ReportBO.getReportByUser(user.getId());
        return this.reports;
    }
    //</editor-fold>
}
